package com.yunwuliu.response;

import com.yunwuliu.eunm.Result;
import lombok.Data;

/**
 * @author 16375
 * @version 1.0
 * @description: 常用响应类
 * @date 2025/7/22 12:16
 */
@Data
public class CommonResponse<T> {
    private int code;
    private String meg;
    private T data;

    public CommonResponse(int code, String meg) {
        this.code = code;
        this.meg = meg;
    }

    public CommonResponse(int code, String meg, T data) {
        this.code = code;
        this.meg = meg;
        this.data = data;
    }

    public static <T> CommonResponse<T> success(T data) {
        return new CommonResponse<>(Result.success(data).getCode(), Result.success( data).getMsg(), data);
    }

    @Override
    public String toString() {
        return "CommonResponse{" +
                "code=" + code +
                ", meg='" + meg + '\'' +
                ", data=" + data +
                '}';
    }
}
